<script type="text/javascript">

    function on_submit(){

        $("#rule_form").submit();
    }
    function selShow(){
        var post_time = $("#post_time").val();
        if(post_time == -1){
            $("#set_post_time").show();
        }else{
            $("#set_post_time").hide();
        }
    }
    $("#add_rules").on("hidden.bs.modal", function() {
        $(this).removeData("bs.modal");
    });
</script>

<div class="tab-pane active" id="horizontal-form">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">×</button>
        <h2 class="modal-title">编辑规则(<?php echo $topic['title']?>)</h2>
    </div>
    <form class="form-horizontal" name="form" id="rule_form" action="index.php?c=<?php echo $_REQUEST["c"]?>&m=<?php echo $_REQUEST["m"]?>" method="post">
        <input type="hidden" name="id" id="id" value="<?php echo $id;?>"/>
        <input type="hidden" name="submits" value="1"/>

        <div class="form-group">
            <label for="post_times" class="col-sm-2 control-label">帖子推荐</label>
            <div class="col-sm-6">
                <label><input type="radio" name="is_hot" <?php if($topic['rule']['is_hot'] == 0){ echo "checked";}?> value="0" checked>  不限</label>
                <label><input type="radio" name="is_hot" <?php if($topic['rule']['is_hot'] == 1){ echo "checked";}?> value="1">  精华</label>
                <label><input type="radio" name="is_hot" <?php if($topic['rule']['is_hot'] == 2){ echo "checked";}?> value="2">  非精华</label>
            </div>
            <div class="col-sm-2">
            </div>
        </div>
        <div class="form-group">
            <label for="post_times" class="col-sm-2 control-label">是否有图片</label>
            <div class="col-sm-6">
                <label><input type="radio" name="is_img" <?php if($topic['rule']['is_img'] == 0){ echo "checked";}?> value="0" checked>  不限</label>
                <label><input type="radio" name="is_img" <?php if($topic['rule']['is_img'] == 2){ echo "checked";}?> value="2">  无图</label>
                <label><input type="radio" name="is_img" <?php if($topic['rule']['is_img'] == 1){ echo "checked";}?> value="1">  有图</label>
            </div>
            <div class="col-sm-2">
            </div>
        </div>
        <div class="form-group">
            <label for="post_times" class="col-sm-2 control-label">发帖时间</label>
            <div class="col-sm-6">
                <select name="post_time" id="post_time" class="form-control" onchange="selShow()">
                    <option value="60" selected>最近两个月</option>
                    <option value="1"  <?php if($topic['rule']['post_time'] == 1){ echo "selected";}?>>最近一天</option>
                    <option value="3"  <?php if($topic['rule']['post_time'] == 3){ echo "selected";}?>>最近三天</option>
                    <option value="7"  <?php if($topic['rule']['post_time'] == 7){ echo "selected";}?>>最近七天</option>
                    <option value="30" <?php if($topic['rule']['post_time'] == 30){ echo "selected";}?>>最近三十天</option>
                    <option value="-1" <?php if(!in_array($topic['rule']['post_time'], array(1,3,7,30,60)) && !empty($chnlPub['post_time'])){ echo "selected";}?>>自定义时间</option>
                </select>
            </div>
            <div class="col-sm-2">
                <input type="text" name="set_post_time" id="set_post_time" class="form-control" value="<?php echo $topic['rule']['set_post_time'];?>" <?php echo !in_array($topic['rule']['post_time'], array(1,3,7,30,60)) && !empty($topic['rule']['set_post_time']) ? 'style="display:inline;"' : 'style="display:none;"';?>/>
            </div>
        </div>
        <div class="form-group">
            <label for="order" class="col-sm-2 control-label">排序条件</label>
            <div class="col-sm-6">
                <select name="order" class="form-control">
                    <option value="2" selected>最多回帖量</option>
<!--                    <option value="1" --><?php //if($topic['rule']['order'] == 1){ echo "selected";}?><!-->最新回复时间</option>-->
                    <option value="3" <?php if($topic['rule']['order'] == 3){ echo "selected";}?>>最多点赞量</option>
                    <option value="4" <?php if($topic['rule']['order'] == 4){ echo "selected";}?>>最多观看量</option>
                    <option value="5" <?php if($topic['rule']['order'] == 5){ echo "selected";}?>>最新发帖时间</option>
                </select>
            </div>
        </div>

        <div class="modal-footer">
            <button type="reset" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="on_submit()" class="btn btn-primary">保存</button>
        </div>

    </form>
</div>